#ifndef POPEN_WRAPPER_H

#define POPEN_WRAPPER_H

#include <cstdio>
#include <string>
#include <iostream>

enum POpenState {STATE_OPEN, STATE_CLOSED, STATE_ERROR, STATE_EOF};


class POpen
{
public:
	POpen(const std::string arg);
	POpen(const char* arg);
	~POpen();
	
	POpenState GetState() const { return state;}
	std::string GetData();
	
private:
	void open(const char* arg);
	void update(); //read as much data as possible from file.
	
	POpenState state;
	FILE *fd;
	std::string data;
};

#endif
